﻿using ConfExpert.Forms.Base;
using DevTeam;
using System;
using System.Data;
using System.Windows.Forms;

namespace ConfExpert.Forms.Du4
{
    public partial class KesimNoAl : XForm
    {
        DataTable dt;
        string idx;
        public KesimNoAl()
        {
            InitializeComponent();
        }

        public KesimNoAl(DataTable _dt,string _idx)
            : this()
        {
            dt = _dt;
            idx = _idx;
        }

        private void KesimNoAl_Load(object sender, EventArgs e)
        {
            dateDeliver.DateTime = DateTime.Now;
            try
            {
                dateTermin.DateTime = (DateTime)dt.Compute("min(KarbelTermin)", "");
            }
            catch (Exception)
            {
                MessageBox.Show("Karbel Termin alanı boş geçilemez!");
            }
            lblAdet.Text = dt.Compute("sum(TotalPerPlan)", "").ToString();
            txtArtikel.Text = dt.Rows[0]["Etiket"].ToString();

            btnOk.Click += new EventHandler(btnOk_Click);
            btnCancel.Click += new EventHandler(btnCancel_Click);
        }

        void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        void btnOk_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            Session.DataManager.ExecuteDataSet("UpdDu4KesimNo", idx, dateTermin.DateTime, dateDeliver.DateTime, txtArtikel.Text, dt.Rows[0]["CuttingGroup"].ToString(), txtNot.Text,WhoAmI);
        }
    }
}